<%@ page import="com.lagou.task.entity.Admin" %>
<%--
  Created by IntelliJ IDEA.
  User: liuyunkai
  Date: 2021/1/9
  Time: 3:44 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    <title>管理员登陆</title>
    <%--导入bootstrap样式--%>
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <%--导入js插件--%>
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        #loginDiv {
            width: 60%;
            height: 60%;
            position: relative;
            top: 350px;
            left: 200px;
        }
        #cookieButton {
            position: relative;
            left: 90px;
            top: 30px;
        }
        #loginError {
            position: relative;
            left: 60px;
        }

    </style>
</head>
<body>
<div class="container-fluid" id="loginDiv">
    <div class="container">
        <%--错误提示--%>
        <c:set var="loginError" value="${loginError}"/>
        <c:if test="${loginError != null }">
            <div class="alert alert-danger col-lg-5" id="loginError">
                <a href="#" class="close" data-dismiss="alert">&times;</a>
                <strong>登陆失败！用户名或密码错误！</strong>
            </div>
        </c:if>
    </div>

    <%-- 获取浏览器端的cookie值 --%>
    <c:set var="adminName" scope="request" value=""/>
    <c:set var="password" scope="request" value=""/>
    <c:forEach var="c" items="${cookie}">
        <c:choose>
            <c:when test="${c.key.equals('adminName')}">
                <c:set var="adminName" scope="request" value="${c.value.value}"/>
            </c:when>

            <c:when test="${c.key.equals('password')}">
                <c:set var="password" scope="request" value="${c.value.value}"/>
            </c:when>
        </c:choose>
    </c:forEach>
    <form class="form-horizontal" action="login" method="post">
        <div class="form-group">
            <label class="col-sm-2 control-label">用户名：</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" placeholder="管理员账号" name="adminName" value="${adminName}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">密&nbsp&nbsp&nbsp&nbsp码：</label>
            <div class="col-sm-4">
                <input type="password" class="form-control" placeholder="管理员密码" name="password" value="${password}">
            </div>
        </div>

        <div class="form-group checkbox" id="cookieButton">
            <label class="col-sm-2 control-label">
                <input type="checkbox" name="remember"> 记住我
            </label>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="submit" class="btn btn-info" id="Adminlogin">登陆</button>
            </div>
        </div>
    </form>
</div>

<script>
    /* 设置错误提示和成功提示存活时间 */
    $("#loginError").delay(2000).fadeOut();
</script>
</body>
</html>